# -*- coding: utf-8 -*-

# __date:       2021/7/2
# __author:     Yang Chao
# __function:   Container With Most Water 盛最多水的容器

from typing import List

class Solution:

    # 枚举法 超时
    def maxArea1(self, height: List[int]) -> int:
        ans = 0
        ln = len(height)
        for i in range(ln - 1):
            for j in range(i + 1, ln):
                ans = max(ans, (j - i) * min(height[i], height[j]))
        return ans

    # 双指针，效率依旧很慢
    def maxArea2(self, height: List[int]) -> int:
        left = 0
        right = len(height) - 1
        ans = 0
        while left < right:
            ans = max(ans, min(height[left], height[right]) * (right - left))
            if height[left] < height[right]:
                left += 1
            else:
                right -= 1
        return ans
